function SkillManager(){
    let obj = {
        skillInfos: globalSkillInfos, //<skillname, <flag,type,preposes>>,  flag: 0-single, 1-multi, type: 技能类别  preposes: [prepose]
        selectedSkills: new Array(),
        impossibles: new Array(),
        GetSelectedSkills: () =>{
            return obj.selectedSkills
        },
        GetSelectedSkillTypes: () =>{
            let rtn = []
            for( let skillname of obj.selectedSkills)
            {
                if(skillname.indexOf('学习') == 0){
                    rtn.push(obj.skillInfos[skillname].type);
                }
            }
            return rtn
        },
        CheckSkill: (skill) =>{ //返回: -1-不会再出现 n-前置距离(0为可以马上出现)
            if(obj.selectedSkills.includes(skill) && obj.skillInfos[skill].flag == 0){
                return -1
            }
            let types = obj.GetSelectedSkillTypes();
            return obj._CalcPreposeSize(skill,types,0)
        },
        _CalcPreposeSize: (skill, types, size)=>{ //计算前置距离（递归）
            if(types.length >= 5 && !types.includes(obj.skillInfos[skill].type)){
                return -1
            }
            if(skill in obj.skillInfos){
                let preposes = obj.skillInfos[skill].preposes
                let skills = obj.selectedSkills.slice(0)
                for(let prepose of preposes)
                {
                    let pos = skills.indexOf(prepose)
                    if(pos == -1){
                        size = obj._CalcPreposeSize(prepose, types, size+1);
                        if(size == -1){
                            return -1;
                        }
                    }
                    skills.splice(pos,1)
                }
            }
            return size;
        },
        _GetBackSkillsLayer1: (skillname) =>{
            let rtn = []
            for(let s in obj.skillInfos)
            {
                for(let prepose of obj.skillInfos[s].preposes)
                {
                    if(skillname == prepose){
                        rtn.push(s)
                        break
                    }
                }
            }
            return rtn
        },
        GetBackSkills: (skill) =>{ //获得后置所有技能
            let L = obj._GetBackSkillsLayer1(skill) //先入先出
            let R = []
            while(L.length > 0){
                let item = L.shift()
                let backs = obj._GetBackSkillsLayer1(item)
                R.push(item)
                if(backs.length > 0){
                    for(let back of backs)
                    {
                        L.push(back)
                    }
                }
            }
            let rtn = []
            for(let r of R)
            {
                let len = obj.CheckSkill(r)
                let s = `${obj.skillInfos[r].type}|${r}|${len}`
                rtn.push(s)
            }
            rtn = [...new Set(rtn)]; //去重
            return rtn
        },
        GetPosibleSkills: (skill) =>{
            let rtn = {}
            for(let skillname in obj.skillInfos)
            {
                let r = obj.CheckSkill(skillname)
                if(r >= 0){
                    rtn[skillname] = {r: r, s: `${obj.skillInfos[skillname].type}|${skillname}|${r}`}
                }
            }
            return rtn;
        },
        RecordSkill: (skill) =>{
            obj.selectedSkills.push(skill)
        },

    }
    return obj
}